package com.yonyou.jrmob.contacts.contact.dbhelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

/****
 * 
 * 描述: 本地数据库
 * 
 * @下午3:28:28
 * @author zhangg
 */
public class DBHelper_ct extends SQLiteOpenHelper {

	/*** 数据库名称 */
	public static final String DATABASE_NAME = "prp.db";
	/*** 最近联系人表名称 */
	public static final String recentlyContacts = "recentlycontacts";
	/*** 数据库版本 **/
	private static final int DATABASE_VERSION = 1;

	public DBHelper_ct(Context context, String name, CursorFactory factory,
					   int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {

	}

	/**
	 * 构造函数
	 * 
	 * @param context
	 */
	public DBHelper_ct(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}




	
	/***
	 * 创建最近联系人表
	 * 
	 * @param db
	 */
	public void createRecentlyContacts(SQLiteDatabase db) {
		// 如果已经存在先删除
		String deletesql = "drop table if  exists " + DBHelper_ct.recentlyContacts;
		db.execSQL(deletesql);
		// 创建表(如果不存在的话)
		String sql = "create table if not exists " + DBHelper_ct.recentlyContacts
				+ "(_id integer primary key autoincrement, "
				+ "user_name varchar(50) " + ", user_mobilephone varchar(20)"
				+ ", user_telephone varchar(20)"+ ", user_email varchar(20)"
				+ ", cuserid varchar(20))";
		//db.execSQL(sql);
	}

	// 如果DATABASE_VERSION值被改为2,系统发现现有数据库版本不同,即会调用onUpgrade
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// db.execSQL("ALTER TABLE person ADD COLUMN other STRING");
	}

}
